package ai.people.netmon.framework.domain.twitter.monitor.request;

import ai.people.netmon.framework.domain.twitter.view.entity.TwitterAccountView;
import ai.people.netmon.framework.model.request.PageKeyWordsRequest;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

/**

 *
 * @author zhenglin
 * @since 2022/3/8
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class MonitorUsersRequest extends PageKeyWordsRequest {

    public LambdaQueryWrapper<TwitterAccountView> createQueryWrapper(){
        LambdaQueryWrapper<TwitterAccountView> queryWrapper = Wrappers.lambdaQuery();
        String searchKeywords = this.getSearchKeywords();
        if (StringUtils.isNotBlank(searchKeywords)){
            queryWrapper.like(TwitterAccountView::getAccountId,searchKeywords).or().like(TwitterAccountView::getAccountName,searchKeywords)
                    .or().like(TwitterAccountView::getAccountLink,searchKeywords);
        }
        return queryWrapper;
    }
}
